# 测试简化的训练接口
# 使用新的前端发送的简化参数结构

Write-Host "测试简化的训练接口..." -ForegroundColor Green

# 测试1年数据范围的简化配置
$body = @{
    train_range = "1_year"
    enable_parallel = $true
    enable_shap = $true
    dynamic_weights = $true
} | ConvertTo-Json

Write-Host "发送训练请求：" -ForegroundColor Yellow
Write-Host $body

try {
    $response = Invoke-RestMethod -Uri "http://localhost:8000/api/v1/enhanced-training/train/start" -Method POST -Body $body -ContentType "application/json"
    
    Write-Host "✅ 训练请求成功发送" -ForegroundColor Green
    Write-Host "响应: " -ForegroundColor Cyan
    $response | ConvertTo-Json -Depth 3
    
    # 等待几秒然后检查状态
    Write-Host "等待5秒后检查训练状态..." -ForegroundColor Yellow
    Start-Sleep -Seconds 5
    
    $status = Invoke-RestMethod -Uri "http://localhost:8000/api/v1/enhanced-training/train/status" -Method GET
    Write-Host "训练状态: " -ForegroundColor Cyan
    $status | ConvertTo-Json -Depth 3
    
} catch {
    Write-Host "❌ 测试失败: $($_.Exception.Message)" -ForegroundColor Red
    Write-Host "详细错误: " -ForegroundColor Red
    $_.Exception | Format-List * -Force
}